## DESCRIPTION

g.proj provides a means of converting a co-ordinate system description (i.e. projection information) between various formats. It requires OGR to compile. The basic functionality of the module is to report the projection information for the current location, either in conventional GRASS (-p flag) or PROJ.4 (-j flag) format.

Projection information may also be output in the Well-Known Text (WKT) format popularised by proprietary GIS. In addition, if one of the parameters georef, wkt, proj4 or epsg is specified, rather than the projection information being read from the current location it is imported from an external source as follows:

georef=filename
  g.proj attempts to invoke GDAL and OGR in turn to read a georeferenced file filename. The projection information will be read from this file. If the file is not georeferenced or cannot be read, XY (unprojected) will be used.
wkt=filename or -
  The file filename should contain a projection description in WKT format with or without line-breaks (e.g. a '.prj' file). If - is given for the filename, the WKT description will be read from stdin rather than a file.
proj4=description or -
  description should be a projection description in PROJ.4 format, enclosed in quotation marks if there are any spaces. If - is given for description, the PROJ.4 description will be read from stdin rather than as a directly-supplied command-line parameter.
epsg=number
  number should correspond to the index number of a valid co-ordinate system in the EPSG database. EPSG code support is based upon a local copy of the GDAL CSV co-ordinate system and datum information files, stored in the directory ${GISBASE}/etc/ogr_csv. These can be updated if necessary to support future revisions of the EPSG database.

The -p, -j, -w, etc. flags are all functional when importing projection information from an external source, meaning that g.proj can be used to convert between representations of the information. It is not required that either the input or output be in GRASS format.

In addition however, if the -c flag is specified, g.proj will create new GRASS projection files (PROJ_INFO, PROJ_UNITS, WIND and DEFAULT_WIND) based on the imported information. If the location parameter is specified in addition to -c, then a new location will be created. Otherwise the projection information files in the current location will be overwritten. The program will warn before doing this only if command-line interactive mode (-i flag) is selected.

The final mode of operation of g.proj is to report on the datum information and datum transformation parameters associated with the co-ordinate system. The -d flag will report a human-readable summary of this.

## NOTES

If the input co-ordinate system contains a datum name but no transformation parameters, and there is more than one suitable parameter set available (according to the files datum.table and datumtransform.table in ${GISBASE}/etc), g.proj will check the value of the datumtrans option and act according to the following:
-1: List available parameter sets in a GUI-parsable (but also human-readable) format and exit.
0 (default): Continue without specifying parameters - if used when creating a location, other GRASS modules will use the "default" (likely non-optimum) parameters for this datum if necessary in the future.
Any other number less than or equal to the number of parameter sets available for this datum: Choose this parameter set and add it to the co-ordinate system description.
If the module is being used from the command-line through an interactive terminal, the -i flag can be specified to enable interactive selection of the parameter set, and the value of datumtrans (if specified) is ignored.
If the -t flag is specified, the module will attempt to change the datum transformation parameters using one of the above two methods even if a valid parameter set is already specified in the input co-ordinate system.

Output is simply based on the input projection information. g.proj does not attempt to verify that the co-ordinate system thus described matches an existing system in use in the world. In particular, this means there are no EPSG Authority codes in the WKT output.

WKT format shows the false eastings and northings in the projected unit (e.g. meters, feet) but in PROJ format it should always be given in meters.

The maximum size of input WKT or PROJ.4 projection descriptions is limited to 8000 bytes.

## EXAMPLES

Print the projection information for the current location:

    g.proj -p

Create a '.prj' file in ESRI format corresponding to the current location:

    g.proj -wef > irish_grid.prj

Read the projection information from a geotiff file and print it in PROJ.4 format:

    g.proj -jf georef=ASTER_DEM20020508161837.tif

Convert the PROJ.4 projection description contained in a text file to WKT format:

    cat proj4.description | g.proj -w proj4=-

Create a new location with the co-ordinate system referred to by EPSG code 4326 (Latitude-Longitude/WGS84), without explicitly specifiying datum transformation parameters:

    g.proj -c epsg=4326 location=latlong

Create a new location with the co-ordinate system referred to by ESRI-EPSG code 900913 (Google Mercator Projection)

    g.proj -c epsg=900913 loc=google

Create a new location with the co-ordinate system referred to by EPSG code 29900 (Irish Grid), selecting datum transformation parameter set no. 2:

    g.proj -c epsg=29900 datumtrans=2 location=irish_grid

Create a new location with the same co-ordinate system as the current location:

    g.proj -c location=newloc

Interactively change/update the datum transformation parameters for the current location:

    g.proj -itc

Create a new location with the co-ordinate system from a WKT definition stored in a text file:

    g.proj -c wkt=irish_grid.prj location=irish_grid

Reproject external raster map to current GRASS projection (does not always make sense!) using the GDAL 'gdalwarp' tool. We recommend to use the ERDAS/Img format and not to use the ESRI style of WKT:

    # example for 30x30 pixel resolution (enforce with -tr to avoid odd values)
    gdalwarp -of HFA -tr 30 30 -t_srs "`g.proj -wf`" aster.img aster_tmerc.img

Reproject external vector map to current GRASS projection using the OGR 'ogr2ogr' tool:

    ogr2ogr -t_srs "`g.proj -wf`" polbnda_italy_GB_ovest.shp polbnda_italy_LL.shp

## REFERENCES

PROJ 4: Projection/datum support library
GDAL raster library and toolset
OGR vector library and toolset

Further reading

- ASPRS Grids and Datum
- MapRef - The Collection of Map Projections and Reference Systems for Europe
- Projections Transform List (PROJ4)

## SEE ALSO

g.setproj
r.in.gdal
v.in.ogr

## AUTHOR

Paul Kelly

Last changed: $Date: 2008-06-07 08:15:50 -0500 (Сб, 07 июн 2008) $